<?php

	include "kernel.php";
    include "adw_functions.php";

    if ($_POST[dopost]) {

        $file = $_FILES[ffile];


        $strs = file($file[tmp_name]);

     	foreach ($strs as $str) {

        	$str = ereg_replace("\r","",$str);
            $str = ereg_replace("\n","",$str);

            $str = explode(";",$str);

            if ($str[0]) {

	            $army = $str[0];
	            $type = $str[1];
	            $planename = $str[2];

	            $plane = GetPlaneIdByName($planename);

			if (!$plane)
				echo "\r\n<br><br>ATTENTION!!! UNKNOWN PLANE NAME: \"$planename\"\r\n<br><br>";

	            for ($i=3; $i<=18; $i++) 
			{

            	    	if ($str[$i])
				{
		                mysql_query("insert into reserv (plane_id, company_id, maxcount, army, typeOf) values ('$plane','".($i-2)."','".intval($str[$i])."','".$army."','".$type."')");
      	                echo "(plane_id, company_id, maxcount, army, typeOf)('$plane','".($i-2)."','".intval($str[$i])."','".$army."','".$type."')<br>\r\n";
				}
	            }
            }

        }

    }

?>

	<form method=post enctype="multipart/form-data">

    <input type=file name=ffile>

	<input type=submit name=dopost value="Add">


	</form>